package com.xcity.game.activity2.singlerecharge;

import com.alibaba.fastjson.TypeReference;
import com.xcity.db.entity.Player;
import com.xcity.game.activity2.singlerecharge.model.ActivityData;
import com.xcity.game.activity2.singlerecharge.model.SingleRechargeData;
import com.xcity.game.common.PlayerPool;

public class SingleRechargeActivityUtils {
	

	public static SingleRechargeData get(Player player) {
		SingleRechargeData data = player.getPool().getObject(PlayerPool.PROPERTY_SINGLE_RECHARGE_DATA, new TypeReference<SingleRechargeData>() {});
		return data;
	}
	
	public static SingleRechargeData get(Player player, ActivityData activityData) {
		SingleRechargeData data = player.getPool().getObject(PlayerPool.PROPERTY_SINGLE_RECHARGE_DATA, new TypeReference<SingleRechargeData>() {});
		if (data == null || data.serial != activityData.serial) {
			data = new SingleRechargeData(activityData.serial);
			player.poolSet(PlayerPool.PROPERTY_SINGLE_RECHARGE_DATA, data);
		}
		return data;
	}
	
	public static void clear(Player player, ActivityData activityData) {
		SingleRechargeData data = get(player);
		if (data != null && data.serial != activityData.serial) {
			player.poolRemove(PlayerPool.PROPERTY_SINGLE_RECHARGE_DATA);
		}
	}
	
}
